﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Sample.GameManagement.Contracts;

namespace Zhaoxi.GameManagement.EntityFrameworkCore.Repositories
{
    public class RepositoryWrapper : IRepositoryWrapper
    {
        private readonly GameManagementDbContext _gameDbContext;
        private IPlayerRepository _player;
        private ICharacterRepository _character;

        public IPlayerRepository Player {
            get { return _player ??= new PlayerRepository(_gameDbContext); }
        }

        public ICharacterRepository Character {
            get { return _character ??= new CharacterRepository(_gameDbContext); }
        }

        public RepositoryWrapper(GameManagementDbContext gameDbContext)
        {
            _gameDbContext = gameDbContext;
        }

        public Task<int> SaveChangesAsync()
        {
            return _gameDbContext.SaveChangesAsync();
        }
    }
}
